package com.service;

import com.bean.ArticleInfo;
import com.dto.Execution;
import com.dto.WebResult;
import com.enums.ArticleEnums;
import com.mapper.ArticleInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.sql.Timestamp;
import java.util.Calendar;
import java.util.List;
import java.util.UUID;

/**
 * Created by Yuicon on 2016/11/3.
 */
@Service
public class ArticleInfoService {

    @Autowired
    private ArticleInfoMapper articleInfoMapper;

    public List<ArticleInfo> findAll(String aaid){
        return articleInfoMapper.findAll(aaid);
    }

    public ArticleInfo findById(String id){
        return articleInfoMapper.findById(id);
    }

    public void insert(String id, String aaid, String title, String uploader, String synopsis){
        ArticleInfo articleInfo =
                new ArticleInfo(id,aaid,title,uploader,new Timestamp(Calendar.getInstance().getTimeInMillis()),synopsis,0,0);
        articleInfoMapper.insert(articleInfo);
    }

    public void insert(ArticleInfo articleInfo){
        articleInfoMapper.insert(articleInfo);
    }

    public void update(String id, String title, String synopsis, int onlookerNum, int commentNum){
        ArticleInfo articleInfo =
                new ArticleInfo(id,title,synopsis,onlookerNum,commentNum);
        articleInfoMapper.update(articleInfo);
    }

    public void update(ArticleInfo articleInfo){
        articleInfoMapper.update(articleInfo);
    }

}
